package OperationTest;

import domain.FileModel;
import domain.OS_operation;

import java.io.*;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class OPTest {
    public void testDemo() throws IOException, ClassNotFoundException {
        OS_operation os = new OS_operation();
        os.createFile("1","txt");
        os.createFile("2","txt");
        os.createFile("3","txt");
        os.createFile("4","txt");
        os.createFile("5","txt");
        os.createFile("6","txt");
        os.createFile("7","txt");
        os.createFile("8","txt");
        os.createFile("9","txt");
        os.PrintFat();
        os.printAllFileModel(os.getRoot(),"");
        os.deleteFile("9");
        os.PrintFat();
        os.printAllFileModel(os.getRoot(),"");
        os.createFile("11","txt");
        os.PrintFat();
    }


    public void TestFindFileByPath(){
        OS_operation os = new OS_operation();
        os.createCatalog("1");
        os.setNowCata(os.getNowCata().getSubCata().get("1"));
        os.createCatalog("3");
        os.setNowCata(os.getNowCata().getSubCata().get("3"));
        os.createFile("demo","txt");
        os.printAllFileModel(os.getRoot(),"");
        String path = "root\\1\\3\\demo";
        System.out.println(os.FindFileByPath(path));
    }


    public void TestFindCataByPath(){
        OS_operation os = new OS_operation();
        os.createCatalog("1");
        os.setNowCata(os.FindCataByPath("root\\1"));
        System.out.println(os.getPath());
        os.createCatalog("2");
        os.setNowCata(os.FindCataByPath("root\\1\\2"));
        System.out.println(os.getPath());
        os.printAllFileModel(os.getRoot(),"");
}

    
    public void TestEditFile(){
        OS_operation os = new OS_operation();
        os.createFile("a","txt");
        os.OpenFile("a");
        os.deleteFile("a");
        os.printAllFileModel(os.getRoot(),"");
    }
}
